let connection=require('./db');
module.exports={
    getArticles:(pageSize,nowPage,callback)=>{
        let sqlStr='select articles.*, users.nickname from articles left join users on articles.userId=users.id limit ? offset ?;select count(*) AS totalCount from articles;'
        // 偏移量= 每页多少条*(当前页码-1)
        let offsetVal= pageSize * (nowPage-1)
        connection.query(sqlStr,[pageSize,offsetVal],(err,result)=>{
            if(err) return callback(err,null)
            callback(null,result)
        })
    }
}